# -*- codeing: utf-8 -*-
# @Time     :2021/12/10 21:37
# @Author   :郭荣杰
#@File      :getSpeed.py
#@Software  : PyCharm
import time
import redis
#127.0.0.1
#192.168.179.140
ip = '192.168.179.140'
password = ''
r = redis.Redis(host=ip, password=password, port=6379, db=0, decode_responses=True)
start = 0
#计算处理订单速度
while True:
    end = int(r.get("TotalOrders"))
    speed = end - start
    print(speed)
    start = end
    time.sleep(1)

#另一种版本计算速度
# start = time.time()
# start_value=int(r1.get("TotalOrders"))
# #long running
# while(True):
#     # print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
#     print( ( float( r1.get("TotalOrders") ) - start_value)/( time.time()-start ) )
#     print("\n")